package com.ducbt.databasehelper;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public abstract class DatabaseHelper extends SQLiteOpenHelper {
	
	public DatabaseHelper(Context context, String databaseName, int version) {
		super(context, databaseName, null, version);
	}
	
	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(getCreateStatement());
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		//Log.w(ListMocDatabaseHelper.class.getName(),"Upgrading database from version " + oldVersion + " to "+ newVersion + ", which will destroy all old data");
		db.execSQL("DROP TABLE IF EXISTS " + getTableName());
		onCreate(db);
	}
	
	protected abstract String getCreateStatement();
	protected abstract String getTableName();
}

